package mylinkedelist;

public class MyLinkedList implements IList{

    static class ListNode{
        public int data;
        public ListNode next;


        public ListNode(int data){
            this.data=data;
        }
    }

    public void createlist(){
        ListNode node1=new ListNode(1);
        ListNode node2=new ListNode(2);
        ListNode node3=new ListNode(3);
        ListNode node4=new ListNode(4);
        ListNode node5=new ListNode(5);


        node1.next=node2;
        node2.next=node3;
        node3.next=node4;
        node4.next=node5;


        head=node1;
    }


    public ListNode head;
    @Override
    public void addFirst(int data) {
        ListNode newH=new ListNode(data);
        if (head==null){
            head=newH;
        }else {
            newH.next=head;
            head=newH;
        }

    }

    @Override
    public void addLast(int data) {
        ListNode node=new ListNode(data);
        if (head==null){
            head=node;
        }else {
            ListNode cur=head;
            while (cur.next!=null){
                cur=cur.next;
            }
            cur.next=node;
        }

    }

    @Override
    public void addIndex(int index, int data) {

    }

    @Override
    public boolean contains(int key) {
        return false;
    }

    @Override
    public void remove(int key) {

    }

    @Override
    public void removeAllKey(int key) {

    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public void clear() {

    }

    @Override
    public void display() {
        ListNode cur=head;
        while (cur!=null){
            System.out.print(cur.data+" ");
            cur=cur.next;
        }
        System.out.println();
    }
}
